﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.Text;
using System.IO;
using System.Net;

namespace BeniBastanYaratProject
{
    public partial class Iletisim : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btn_gonder_Click(object sender, EventArgs e)
        {
            MailMessage mm   = new MailMessage();
            mm.BodyEncoding  = Encoding.UTF8;
            mm.IsBodyHtml    = true;
            mm.Priority      = MailPriority.High;
            StringBuilder sb = new StringBuilder();
            StreamReader rdr = new StreamReader(Server.MapPath("~/Iletisim/Taslak.htm"));
            sb.Append(rdr.ReadToEnd());
            sb.Replace("{Kullanici Adi}", txt_name.Text);
            sb.Replace("{E_Mail}", txt_email.Text);
            sb.Replace("{Konu}", txt_konu.Text);
            sb.Replace("{Mesaj}", txt_msj.Text);
            
            mm.Body = sb.ToString();
            mm.From = new MailAddress("deneme480@gmail.com");//gonderen
            mm.To.Add(new MailAddress("deneme480@gmail.com"));//alıcı

            SmtpClient sc = new SmtpClient();
            sc.Host = "smtp.gmail.com";
            sc.Port = 587;
            sc.EnableSsl = true;
            sc.Credentials = new NetworkCredential("deneme480@gmail.com", "denemesifre");
           
            sc.Send(mm);
        }
    }
}